package com.zzq.base.awesome.controller;

import com.zzq.base.awesome.entity.Result;
import com.zzq.base.awesome.utils.JwtTokenUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

import java.util.ArrayList;
import java.util.List;

import static com.zzq.base.awesome.entity.CommonData.TOKENTAG;

@RestController
@RequestMapping("/common")
@Slf4j
public class CommonController {
    @GetMapping("/test")
    private String getA() {
        log.info("receive");
        return "test String";
    }

    @PostMapping("/test")
    private String post(HttpServletResponse response) {
        log.info("receive");
        response.addHeader(TOKENTAG, JwtTokenUtils.getJwtToken("1"));
        return "test String post";
    }

    @GetMapping("/asd")
    private Result<String> asd() {
        log.info("receive");
        return Result.buildSuccess("test String");
    }

    @PostMapping("/asd")
    private Result<String> posasdt(HttpServletResponse response) {
        log.info("receive");
        response.addHeader(TOKENTAG, JwtTokenUtils.getJwtToken("1"));
        return Result.buildSuccess("test String post");
    }

    @GetMapping("/tempTest")
    private Result<List<String>> geas(){
        return Result.buildSuccess(new ArrayList<>());
    }

}
